//
//  TranslateRightCell.m
//  语音翻译合成Demo
//
//  Created by 王鹏宇 on 2018/2/26.
//  Copyright © 2018年 王鹏宇. All rights reserved.
//

#import "TranslateRightCell.h"
#import "Const_OC.h"

@implementation TranslateRightCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    self.languageBtn.layer.cornerRadius = 15;
    self.languageBtn.clipsToBounds = YES;
    [self.languageBtn setBackgroundColor:kThemeRedColor];
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    self.languageLabel.textColor = kContentColor;
    self.translationLabel.textColor = kSubitleColor;
}


- (IBAction)play:(UIButton *)sender {
    
    if (_delegate && [_delegate respondsToSelector:@selector(playTheSpeech:Translation:)]) {
        
        [_delegate playTheSpeech:self.model.translationStr Translation:self.model.toLanguageType];
        sender.userInteractionEnabled = NO;
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            sender.userInteractionEnabled = YES;
        });
    }
}


- (void)configData:(TranslationModel *)model {
    
    self.model = model;
    
    if (model.language_local.length > 0) {
        [self.languageBtn setTitle:[LocalizedString(model.language_local) substringToIndex:1] forState:UIControlStateNormal];
    }
    self.languageLabel.text = model.languageStr;
    
    CGFloat height = [model.languageStr heightForCommentWithFontSize:14 width:kScreenWidth - 140];
    self.languageLabelHeight.constant = height;
    self.translationLabel.text = model.translationStr;
    
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
